package uniandes.dermatologia;

import uniandes.dermatologia.singleton.DermatologiaUniandesApp;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Typeface;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class MainActivity extends Activity {
	
	

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);

		getActionBar().setDisplayHomeAsUpEnabled(false);

		TextView uniandes = (TextView) findViewById(R.id.lblUniandes);

		Button btnNew = (Button) findViewById(R.id.btnNewConsultation);
		Button btnRecords = (Button) findViewById(R.id.btnRecords);
		Button btnTraining = (Button)findViewById(R.id.btnTraining);

		Typeface font = Typeface.createFromAsset(getAssets(),
				"fonts/Roboto-Bold.ttf");

		Typeface fontThin = Typeface.createFromAsset(getAssets(),
				"fonts/Roboto-Italic.ttf");

		uniandes.setTypeface(font);

		btnNew.setTypeface(fontThin);
		btnRecords.setTypeface(fontThin);
		btnTraining.setTypeface(fontThin);
		
		btnTraining.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				beginTraining(v);
			}
		});

	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		// getMenuInflater().inflate(R.menu.main, menu);
		return false;
	}

	public void beginConsultation(View view) {
		Intent intent = new Intent(this, IdentificationActivity.class);
		// Intent intent = new Intent(this, TestActivity.class);
		startActivity(intent);
	}

	public void queryRecords(View view) {
		// ((DermatologiaUniandesApp) getApplication()).beginConsultation();
		Intent intent = new Intent(this, RecordsActivity.class);
		// Intent intent = new Intent(this, QuestionnaireActivity.class);
		startActivity(intent);
	}
	
	public void beginTraining(View view)
	{
		DermatologiaUniandesApp app = (DermatologiaUniandesApp)getApplication();
		if(app.hasUser())
		{
			app.login(this);
		}
		else
		{
			Intent intent = new Intent(this, LoginActivity.class);
			startActivity(intent);
		}
	}
	
	
}
